home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_02
/
allison
/
max1.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1993-11-30
|
374 b
|
28 lines
LISTING 1 - Finds the largest of n integers
/* max1.c */
#include <stdio.h>
int maxn(size_t n,...)
{
int x;
int *p = (int *) (&n + 1);
int m = *p;
while (--n)
{
x = *++p;
if (x > m)
m = x;
}
return m;
}
main()
{
printf("max = %d\n",maxn(3,1,3,2));
return 0;
}
/* Output:
max = 3